﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for busMenu
/// </summary>
public class busMenu
{
    public busMenu()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public bool checkQuyenVaoTrang(int userid, int trang)
    {
        return new datMenu().checkQuyenVaoTrang(userid, trang);
    }
    public List<entMenu> getMenuCha(int userid)
    {
        return new datMenu().getMenuCha(userid);
    }
    public List<entMenu> getMenuCon(int userid, int menuchaid)
    {
        return new datMenu().getMenuCon(userid, menuchaid);
    }
    public string getStringMenu(int userid, int trang)
    {
        string html = "";
        List<entMenu> lstcha = new List<entMenu>();
        List<entMenu> lstcon = new List<entMenu>();
        lstcha = getMenuCha(userid);
        foreach (entMenu item in lstcha)
        {
            lstcon = new List<entMenu>();
            lstcon = getMenuCon(userid, item.MenuId);
            string classcss = "";
            if (item.MenuId == trang)
            {
                classcss = "current open";
            }
            else
            {
                classcss = "";
            }
            if (lstcon.Count == 0)
            {
               
                html += " <li class=\""+classcss+"\"><a href=\"" + item.path + "\"><i class=\"icon-th\"></i>" + item.TenMenu + "</a></li>";
            }
            else
            {
                html += "<li  id=\"li1\" runat=\"server\" class=\"has_submenu "+classcss+"\"><a href=\"" + item.path + "\"><i class=\"icon-sitemap\"></i>" + item.TenMenu + "<span class=\"caret pull-right\"></span></a><ul>";
                foreach (entMenu itemcon in lstcon)
                {
                    html += "  <li><a href=\"" + itemcon.path + "\">" + itemcon.TenMenu + "</a></li>";
                }
                html += "</ul></li>";

            }
        }
        return html;
    }
    public string getStringMainMenu(int userid)
    {
        string html = "";
        List<entMenu> lstcha = new List<entMenu>();
        lstcha = getMenuCha(userid);
        foreach (entMenu item in lstcha)
        {
                html+="<a href=\""+item.path+"\" class=\"shortcut\"><i class=\"shortcut-icon "+item.Icon+"\"></i><span class=\"shortcut-label\">"+item.TenMenu+"</span> </a>";  
        }
        return html;
    }
}